/**
 *
 * \file CMessageBox.cpp
 * \brief This file contains the CMessageBox class implementation.
 * \author Vladimir Klubkov (aka marked)
 *
 * Last changes date:
 * \date 15.03.2011
 *
 * Copyright 2011 Vladimir Klubkov <marked-one@yandex.ru>
 *
 * This file is part of OOXlib.
 *
 * OOXLib is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * OOXlib is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with OOXlib; if not, you can try to find  it here:
 * http://www.gnu.org/licenses/gpl.txt
 * or write to the Free Software Foundation, Inc., 59 Temple Place,
 * Suite 330, Boston, MA  02111-1307  USA
 *
 */

#include "../include/CMessageBox.h"

namespace OOXlib {

/**
 * Constructor.
 * \param pXServerConnection A pointer to the CXServerConnection object.
 * \param pScreen Pointer to the CScreen object.
 * \param WindowName Window name.
 * \param MessageText Text to draw.
 * \param Type Message box type.
 * \param pBackgroundColor Pointer to the CColor bject, which contains the background color.
 * \param pTextColor Pointer to the CColor bject, which contains the text color.
 * \param iHorizontalOffset Horizontal offset - default margins/free space betweeen elements.
 * \param iVerticalOffset Vertical offset - default margins/free space betweeen elements.
 */
CMessageBox::CMessageBox(const CXServerConnection *pXServerConnection, const CScreen *pScreen, const ::std::string &WindowName, const ::std::string &MessageText, const OOXLIB_MESSAGEBOX_TYPE &Type,
                         const CColor *pBackgroundColor, const CColor *pTextColor, const unsigned int iHorizontalOffset, const unsigned int iVerticalOffset) {
    if(NULL == pXServerConnection) {
        OOXLib_THROW(CNULLPtrConnectionException);
    }
    if(NULL == pScreen) {
        OOXLib_THROW(CNULLPtrScreenException);
    }
    CDefaultEventHandler deh(pXServerConnection);
    switch(Type) {
        case OOXLIB_MESSAGEBOX_ERROR: {
            CMessageBoxWindow mbw(pXServerConnection, pScreen, CUInt2dRectangle(0, 0, 1, 1), &deh, WindowName, MessageText, "OOXlib/resource/error_icon.xpm", "OOXlib/resource/error.xpm", pBackgroundColor, pTextColor, iHorizontalOffset, iVerticalOffset);
            mbw.Show();
            mbw.Hide();
            break;
        } case OOXLIB_MESSAGEBOX_WARNING: {
            CMessageBoxWindow mbw(pXServerConnection, pScreen, CUInt2dRectangle(0, 0, 1, 1), &deh, WindowName, MessageText, "OOXlib/resource/warning_icon.xpm", "OOXlib/resource/warning.xpm", pBackgroundColor, pTextColor, iHorizontalOffset, iVerticalOffset);
            mbw.Show();
            mbw.Hide();
            break;
        } default:
            break;
    }
}

} // OOXlib
